package xworker;

import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import xworker.com.google.proto.ProtobufMessageFactory;

public class BuilderFactoryRegister {
    public static void regist(){
        Thing thing = World.getInstance().getThing("xworker.gluon.netty.ClientClient/@Handlers/@SelfProtobufDecoder/@ProtobufMessageFactory");
        ProtobufMessageFactory messageFactory = thing.doAction("getMessageFactory", new ActionContext());

        messageFactory.registBuilderFactory("HeartBeat", xworker.gluon.netty.protocols.GluonMessages.HeartBeat::newBuilder);
        messageFactory.registBuilderFactory("SendThingToClientResp", xworker.gluon.netty.protocols.GluonMessages.SendThingToClientResp::newBuilder);
        messageFactory.registBuilderFactory("ClientReceiveThing", xworker.gluon.netty.protocols.GluonMessages.ClientReceiveThing::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$SendThingToClientResp", xworker.gluon.netty.protocols.GluonMessages.SendThingToClientResp::newBuilder);
        messageFactory.registBuilderFactory("RegistProviderResp", xworker.gluon.netty.protocols.GluonMessages.RegistProviderResp::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$HeartBeat", xworker.gluon.netty.protocols.GluonMessages.HeartBeat::newBuilder);
        messageFactory.registBuilderFactory("ConnectProviderResp", xworker.gluon.netty.protocols.GluonMessages.ConnectProviderResp::newBuilder);
        messageFactory.registBuilderFactory("ConnectProviderReq", xworker.gluon.netty.protocols.GluonMessages.ConnectProviderReq::newBuilder);
        messageFactory.registBuilderFactory("ListClientsReq", xworker.gluon.netty.protocols.GluonMessages.ListClientsReq::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$ClientReceiveThing", xworker.gluon.netty.protocols.GluonMessages.ClientReceiveThing::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$ConnectProviderResp", xworker.gluon.netty.protocols.GluonMessages.ConnectProviderResp::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$RegistProviderResp", xworker.gluon.netty.protocols.GluonMessages.RegistProviderResp::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$ListClientsResp", xworker.gluon.netty.protocols.GluonMessages.ListClientsResp::newBuilder);
        messageFactory.registBuilderFactory("ListClientsResp", xworker.gluon.netty.protocols.GluonMessages.ListClientsResp::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$Client", xworker.gluon.netty.protocols.GluonMessages.Client::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$ConnectProviderReq", xworker.gluon.netty.protocols.GluonMessages.ConnectProviderReq::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$ListClientsReq", xworker.gluon.netty.protocols.GluonMessages.ListClientsReq::newBuilder);
        messageFactory.registBuilderFactory("Client", xworker.gluon.netty.protocols.GluonMessages.Client::newBuilder);
        messageFactory.registBuilderFactory("SendThingToClientReq", xworker.gluon.netty.protocols.GluonMessages.SendThingToClientReq::newBuilder);
        messageFactory.registBuilderFactory("RegistProviderReq", xworker.gluon.netty.protocols.GluonMessages.RegistProviderReq::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$RegistProviderReq", xworker.gluon.netty.protocols.GluonMessages.RegistProviderReq::newBuilder);
        messageFactory.registBuilderFactory("xworker.gluon.netty.protocols.GluonMessages$SendThingToClientReq", xworker.gluon.netty.protocols.GluonMessages.SendThingToClientReq::newBuilder);
    }

    public static void main(String[] args) {
        try{
            World world = World.getInstance();
            world.init("./xworker/");

            Thing thing = World.getInstance().getThing("xworker.gluon.netty.ClientClient/@Handlers/@SelfProtobufDecoder/@ProtobufMessageFactory");
            ProtobufMessageFactory messageFactory = thing.doAction("getMessageFactory", new ActionContext());
            System.out.println(messageFactory.generateBuilderFactoryCode());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
